package shiyanshi.qiandao.demo.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import shiyanshi.qiandao.demo.Entity.Qiandao_Records;
import shiyanshi.qiandao.demo.Entity.User;
import shiyanshi.qiandao.demo.Services.UserService;
import shiyanshi.qiandao.demo.util.jsontest;

import java.util.List;

/**
 * @Description:
 * @Author: Z Y F
 * @CreateDate: 2021/6/19 11:02
 **/

@Controller
public class UserController {
    @Autowired
    UserService userService;


    @RequestMapping("/regist")
    @ResponseBody
    public boolean regist(String name, String stuid) throws Exception {
        if (name == null || stuid == null) {
            System.out.println("用户名或者学号为空");
            return false;
        }
        else{
            System.out.println(name);
            System.out.println(stuid);
//            System.out.println(userServices.regist(name, stuid));
            return userService.regist(name,stuid);
        }
    }
    @RequestMapping("/denglu")
    @ResponseBody
    public boolean denglu(String name, String stuid) {
        if (name == null || stuid == null) {
            System.out.println("用户名或者学号为空");
            return false;
        }
        else{
            return userService.denglu(name,stuid);
        }
    }

    @RequestMapping("/sign")
    @ResponseBody
    private boolean sign(String stuid) {
        if (stuid == null) {
            System.out.println("stuid为空");
            return false;
        } else {
            System.out.println(stuid + "签到");
            return userService.sign(stuid);
        }
    }

    @RequestMapping("chaxun")
    public void chaxun() throws Exception {
        List<Qiandao_Records> list = userService.chaxun();
        jsontest.charu(list);
    }

    public boolean panduan(int qiandao_stuid){
        boolean flag=userService.panduan(qiandao_stuid);
        return flag;
    }

    @RequestMapping("/endtime")
    @ResponseBody
    public void endtime(Integer qiandao_stuid){
        userService.endtime(qiandao_stuid);
    }
}
